#define sql(x) (ll)(__builtin_sqrtl(x))
void solve()
{
  ll n;
  cin >> n;

  if (n == 0) {
    cout << 0 << ' ' << 0 << '\n';
    return;
  }

  ll l = 1, r = sql(n) + 1, f = 0;

  auto calc = [&](ll m) {
    return 3ll * m * (m + 1);
  };

  while (l <= r) {
    ll mid = (l + r) >> 1;
    if (calc(mid) < n) {
      l = mid + 1;
    } else {
      f = mid;
      r = mid - 1;
    }
  }

  n -= calc(f - 1);
  ll p = n / f, q = n % f;

  ll x = f * 2, y = 0;
  if (!q) {
    q = f;
    p--;
  }
  if (p == 0) {
    x = f * 2 - q, y = q * 2;
  } else if (p == 1) {
    x = -2 * q + f, y = f * 2;
  } else if (p == 2) {
    x = -f - q, y = f * 2 - q * 2;
  } else if (p == 3) {
    x = -2 * f + q, y = -q * 2;
  } else if (p == 4) {
    x = -f + 2 * q, y = -f * 2;
  } else {
    x = f + q, y = -f * 2 + 2 * q;
  }

  cout << x << ' ' << y << '\n';
}